<template>
  <view class="container">
    <view class="example">
      <uni-forms ref="form" :model="materialTypeAddForm" :rules="rules" labelWidth="80px">

        <uni-forms-item label="饲料类型" name="materiaFeedType" required>
          <uni-easyinput v-model="materialTypeAddForm.materiaFeedType" placeholder="请输入饲料类型" />
        </uni-forms-item>

		<uni-forms-item label="备注">
			<uni-easyinput type="textarea" v-model="materialTypeAddForm.remark" placeholder="请输入备注" />
		</uni-forms-item>
      </uni-forms>
      <button type="primary" plain="true" @click="submit('form')">提交</button>
    </view>
  </view>
</template>

<script>
	import {
		listType,
		addType,
		getType,
		updateType,
		delType
	} from "@/api/hmy/material";

export default {
  name: "MaterialType",
  data() {
    return {

		materialTypeAddForm: {},
		rules: {
			materiaFeedType: {
				rules: [{required: true, errorMessage: '饲料种类不能为空'}]
			}
	    },
	}
  },
  methods: {
    submit(form) {
      this.$refs[form].validate().then(res => {
        addType(this.materialTypeAddForm).then(response => {
          this.$modal.msgSuccess("新增成功")
		  setTimeout(()=>{
		  	this.$tab.navigateTo('/pages/hmy/material/materialTypeAdd');
		  },1000)
		  
        })
      })
    },
  }
}
</script>

<style lang="scss">
	
  /* #ifndef APP-NVUE */
  page {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    min-height: 100%;
    height: auto;
  }

  view {
    font-size: 16px;
    line-height: inherit;
  }
  /* #endif */
  .code{
	margin-bottom :5px;
  }
  .icon{
	float:right;
	margin-right:10px;
	margin-top :5px;
  }
  .message{
	margin-top:5px;
	color: #989897;
	line-height: 25px;
  }

  
  .example {
    padding: 15px;
    background-color: #fff;
  }
  
  .segmented-control {
    margin-bottom: 15px;
  }
  
  .button-group {
    margin-top: 15px;
    display: flex;
    justify-content: space-around;
  }
  
  .form-item {
    display: flex;
    align-items: center;
    flex: 1;
  }
  
  .button {
    display: flex;
    align-items: center;
    height: 35px;
    line-height: 35px;
    margin-left: 10px;
  }
</style>

